// redux切片 就是将单个功能的reducer逻辑和action整合

// 可以使用createSlice定义一个切片 也就是vuex的module
import { createSlice } from '@reduxjs/toolkit';
const counterSlice = createSlice({
    name: "counter",
    initialState: {
        count: 0
    },
    reducers: {
        increase: state => {
            state.count += 1
        }
    }
})

// 导出切片的action
export const { increase } = counterSlice.actions;
// 导出切片的state数据
export const selectCount = state => state.counter.count;
// 导出整个切片reducer函数
export default counterSlice.reducer;